import { onScopeDispose } from 'vue'
import bus from '@/libs/bus'

const openEventName = 'open-widget-contextmenu'

// 发送控件菜单事件
export const emitOpenContextmenuEvent = data => {
    bus.emit(openEventName, data)
}

// 接收控件菜单事件
export const onOpenContextmenuEvent = callback => {
    bus.on(openEventName, callback)

    onScopeDispose(() => {
        bus.off(openEventName, callback)
    })
}